package eight.test_8_11;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class TestMain1 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        HashMap<Integer,int[]> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            int p = scanner.nextInt();
            int x = scanner.nextInt();
            int d = scanner.nextInt();
            int[] arr = {x,d};
            map.put(p,arr);
        }
        int count = -1;
        for (int i = 1; i <= n; i++) {
            int[] arr = map.get(i);
            int x = arr[0];
            int d = arr[1];
            while (x <= count) {
                x += d;
            }
            count = x;
        }
        System.out.println(count);
    }
}
